This is the first issue of Windoid - the newsletter for the Apple HyperCard User’s Group. We hope the user group and newsletter will create a forum for information about HyperCard, including tips and techniques in various accessible formats to make your use of HyperCard even more valuable, flexible, and fun.
We will bring you articles written by the development team and will make efforts to take your questions and problems directly to the source for an answer.
In addition, and most importantly, Windoid will create a forum for the open sharing of stackware and information.
Bill and Dan have shown a remarkable ability to immediately understand the needs, ideas, and suggestions of HyperCard users. The members of the team have thus been able to assist greatly in shaping HyperCard into what it is today. The continuing interest in user input gives users a unique opportunity to help shape HyperCard’s future.
This newsletter provides an opportunity for its readers to contribute to the continued genesis of HyperCard. With your assistance we can continue to bring to HyperCard added depth and functionality. In the back of every issue will be a form for you to keep by your Macintosh™. This form will give you the unique opportunity to be able to participate in the continued development of HyperCard.
If you have a bug, suggestion, or comment fill
out the form and send it to:
AHUG
C/O David Leffler
Apple Computer Inc.
MS 27AQ
20525 Mariani Blvd.
Cupertino, CA 95014
Or copy the form's format and AppleLink™ it to:
HYPERBUG$
====================
Ask the Team...
The HyperCard test team has consented to provide us with a series of tips and techniques based on frequent user questions. Please send in your questions and they will try to answer the most consistently asked.
How can I create a script that will enable me to double-click an icon button?
Consider creating a button script like the following.
The following handler makes a button that will detect a double-click on itself. It waits 30 ticks for the 2nd click then times out.
Put this handler into a button’s script, then add whatever special things you want your button to do when double-clicked. Adjust the timeout value if you want it to wait longer (or shorter). A tick is 1/60th of a second.
on mouseUp
put the ticks into originalTicks
repeat until the mouseClick
if the ticks - originalTicks > 30
then exit mouseUp
end repeat
-- Put here whatever you want the
--button to do when double-clicked.
-- For example:
Play “Boing”
end mouseUp
How can I get a word in a field to do something when I click on it?
One way would be to put a transparent button over the text. If you want to be able to move the word around inside the field without having to move the transparent button with it, you can use the following “sticky button” technique.
The following script gets put into the field:
On Mousedown
Set locktext of me to false
click at the clickloc
click at the clickloc
if the selection is “Apple” then
answer “What kind of Apple:” with
“Macintosh” or “Apple II”
else
put “I don’t know that word”
into msg
end if
set locktext of me to true
End Mousedown
Note: MouseDown, mouseStillDown, and mouseUp messages only get sent to a field when that field is locked. It is therefore necessary to lock a field when expecting that field to deal with any of these messages.
The idea behind sticky buttons is to cause a word to be selected (highlighted) with a single mouse click. ‘The selection’ then becomes a container.
In the above script, we first unlock the field so that we can create a selection. Next, we want to make Hypercard believe that we have double clicked a word, when we really have clicked it only once. This is done in the next two lines of the script. Clicking at the clickloc forces Hypercard to click twice at the same location clicked at by the user. A highlighted selection is then created. Once a word is highlighted, we can use the Hypercard function ‘the selection’ to find out what that word is.
Comparison can be done using multiple IF THEN statements or by the use of a word-list field. In the above script, we do a very simple IF THEN ELSE comparison which only looks for the word APPLE. When found, it puts up a dialog. If any other word is clicked, a generic message is placed in the message box. Remember that you do not need to show the message box every time you want to write into it. Hypercard displays the message box automatically whenever text is placed inside it.
How can I find out which line of a field a user has clicked in?
It is easy to calculate using information that can be obtained about a given field.
First of all, we can find out what size rectangle a field occupies by using the field property, RECT. Short for rectangle, RECT returns four numbers in a comma separated list. The numbers represent the upper-left and lower-right screen coordinates for that field.
Next, we can find out what the line height of each line of a field is by using the field property, TEXTHEIGHT. As you might have guessed, each line of a field can really be expressed as a multipleof the line height. Unfortunately, we must determine that multiple using the screen coordinates. Here’s a user defined function that will do just that:
Function Clickline
return ((item 2 of the
clickloc - item 2 of the rect of the
target) div the textheight of the
target) + 1
End Clickline
on openField
put clickline() into msg
pass openField
end openField
Ignore the openField handler for now, but take a look at the function. As you may remember, the Hypercard function, THE TARGET, returns the name and id of the object which last received a message. Likewise, the Hypercard function THE CLICKLOC returns the horizontal and vertical screen position of the last mouse click as two comma separated integers. With that knowledge, let’s dissect the function Clickline() (yes, you need the parentheses).
The function returns an integer which represents the number of the line of any field clicked in.
Here’s how the function determines the field’s line number. First, it takes the vertical location clicked at by the user (item 2 of the clickloc) and subtracts the top of the field (item 2 of the rect) to determine how many pixels are between the top of the field and the location clicked at. Once this is known, determining the line number is a matter of dividing those pixels by the TEXTHEIGHT. This is what the rest of the function does. We add 1 because Clickline() returns a zero for line 1.
Clickline() is very flexible. In the openfield handler shown above for example, we use clickline() with a put statement, treating it just like the number it returns. You can also use it with an IF THEN statement or any place where you would use the number itself. All you need do is replace the ‘put line’ of the openfield handler with your script.
What about scrolling fields?
An interesting exception arises when using scrolling fields. The above function does not account for lines that may have scrolled off of the screen. It looks only at the visible area of the field. Consider the following function:
Function Clickline
return (((item 2 of the
clickloc - item 2 of the rect of the
target) div the textheight of the
target) + 1 + trunc(scroll of the
target/textheight of the target))
End Clickline
It adds the number of lines that have scrolled off the screen to the total number of visible lines. The field property SCROLL returns the number of pixels scrolled off the top of the field. When divided by the TEXTHEIGHT, this yields the number of lines. Since a full line may not have scrolled by, it is necessary to truncate the value using the TRUNC function.
Put both the function definition and the openfield handler in your home script where they can be used by any field in any stack.
How can I hide buttons from command-option key peek?
When you don’t want people peeking at your buttons, it is necessary to trap the command and option keys. While there are several ways of doing this, here is one that is simple and works about 99% of the time.
The basic idea is to take the user to another card when the command and option keys are both pressed. This can be a “no peeking” card or a rules card or some other kind of card. When the user releases both keys, you then return to the card the user was viewing before trying to peek. Following are the two scripts that accomplish this. Put the top one in your stack script and the other in the “no peeking” card script.
For the stack script:
On Idle
if the commandkey is down and
the optionkey is down then
push this card
go card “no peeking”
end if
end Idle
For the “no peeking” card script:
On Idle
if the commankey is up and
the optionkey is up then
pop card
end if
End Idle
====================
Stack Building Hints
Beware of relying entirely on “Go Back” buttons for navigation through your stack. A good technique is: On openCard “push recent card”, which remembers where you just came from. Then when you do a “pop card” you will always go to that recent location.
If you suspect that your pushes and pops are not in sync, add the following handlers to your stack script to help you sort them out.
on pop params
put the params after msg
pass pop
end pop
on push params
put the params after msg
pass push
end push
====================
Power User Tips
• Create a button on your Home card with a script that says, 'go to stack "the stack you want”.' When you click on it, not finding a stack by that name it will put up SFGetfile asking “Where is the stack you want?”
• To zoom directly to the script of an object, hold down the Shift key while double clicking on the object, or while choosing Object "Info...".
• Do not name a button or a field with a name that begins with a numeric character. This causes problems in that if you ask for a button “1812” HyperCard looks for the button whose number, not name, is 1812.
• In the button or field tools, holding the shift key down when dragging constrains the movement horizontally or vertically, making it easy to drag in a straight line.
• With any tool, Option-Drag in Fatbits allows you to scroll the screen.
• To “pre warm” the cards in a stack so that “show all cards” will really cook through the stack, put an "on openStack" script that locks the screen, shows all cards, and then unlocks the screen. This quickly and invisibly caches all the cards, so that "show card" scripts will work at optimum speed.
• If you are running on a Mac II and want to see Visual Effects, be sure to set the monitor to 2 bit mode.
============
Volume 1 Number 2
Windoid provides an opportunity for its readers to contribute to the ongoing growth and excellence of HyperCard™. With your assistance we can continue to bring to HyperCard added depth and functionality. In the back of every issue will be a form for you to keep by your Macintosh™. This form will give you the unique opportunity to be able to participate in the continued development of HyperCard.
If you have a bug, suggestion, comment, or just want to know the best way to do something in HyperCard, you can fill out the form and send it to: AHUG c/o David Leffler,
Apple Computer, Inc., MS/27-AQ, 10500 N. DeAnza Blvd.,
Cupertino, CA 95014. Or copy the format and Apple-Link™ it to HYPERBUG$.
We will read all the forms returned and address questions
that are being asked by HyperCard users. We will ask the team and provide you with an answer and publish the answers in this newsletter. In this way we can provide for your needs in future versions of HyperCard.
Windoid is trying to make a difference in the way that you work with HyperCard. We would like your input. What sort of stacks are you using, what kinds of stacks are you building, and what are some of the joys and frustrations you are experiencing. We really want to know!
Bill and Dan are receptive to user input and this is your chance to make a difference in the word.
==========
In this second issue of Windoid, we have listened to those who have made a contribution and have needed information. In this issue we will address some of the areas that people have questioned us about and talk in depth about importing text files.
==========
Importing Text
by Gary Bond
Many people have large amounts of data stored in text files. They would like to move this information into Hyper-Card stacks. There are many ways to import files, and we have included in this issue what we feel addresses most of your needs. We have sifted through the many different ways our users have come up with to import files, and we have chosen a few of the most simple and flexible.
This issue will deal with import scripts, and next issue will deal with planning the stack and the Universal Import Button.
When importing text into Hypercard, you must consider how you want the text to appear. Should it fill a single field? Should it create new fields and new cards for each imported text record? How much of a field should you fill with text? Will it appear in scrolling fields? What kind of text will be imported? These are all questions that need to be answered before you begin writing your script. This article will explore the two kinds of text and answer some of these questions.
For the most part, there are two types of text files. The first is the common document file which is usually nothing more than a Macwrite or Word document saved as a text file. All of the characters in this kind of file are usually in printable ASCII format.
The second kind of text file is sometimes generated by a database product such as Omnis or 4th Dimension. This kind of file is broken down into two parts. These parts are records (which are considered to be separate and distinct groups of information) and fields (which are subunits of information within records). A record can contain several fields with each field capable of holding a different kind of information. In a mailing list for example, each person in the mailing list would be a record in the database while the information about that person such as their name, address, city, state and zip would be fields of information within the individual records. Notice that each record in this kind of file has the same number of fields.
Below are some common scripts for reading and writing the first kind of text file:
Simple read from a text file:
On mouseup
Open file filename
Repeat
Read from file filename for 16384 —fastest/most efficient read
If it is empty then exit repeat —leave when out of characters
Put it after var —continue to build a variable with incoming text
—Could also put after a field but must respect the 32K field limit
End repeat
Close file filename
End mouseup
On mouseup
Open file filename
Write var to file filename
—Ex: Write field fieldname to file filename
—Ex: Write Msg to file filename
—Ex: Write the selection to file filename
Close file filename
End mouseup
On mouseup
Open file filename
Repeat—Must read current file info then add new info & write it out
Read from file filename for 16384
If it is empty then exit repeat
Put it after var1
End repeat
Put var2 & return after var1
Write var1 to file filename
Close file filename
End mouseup
==========
HyperCard Hints
by Phil Wyman
1. The DoMenu command will execute DAs. For example, DoMenu “Calculator”.”
2. “It” is a local system variable, not a global.
3. “Set Cursor” command normally uses the following:
“Set cursor to 1” = I-Beam
“Set cursor to 2” = crossbar
“Set cursor to 3” = thick crsbar
“Set cursor to 4” = watch
“Set cursor to 5” = arrow or browse tool
4. “Set lockmessages to true” does not work in the message box. This is because “lockmessages” is turned off during idle. Therefore, lockmessages can only be used in a script.
5. If you don’t see the menu bar on an application, Command-Spacebar will allow you to see and use the menu bar.
6. Option-O both in and out of Fatbits will show you where opaque white exists on your card if you’re in Paint Tools.
7. Command-Drag sizes (elongates) a selected picture in HyperCard. Command-Shift-Drag will enlarge and shrink the selected picture proportionally.
8. When you are trying to intercept an arrowkey, you must use the message “on arrowkey” with the argument “var.” Then you must see if “var” equals “left” or “right” or “up” or “down.” For example:
on arrowkey var
if var = “left” then exit arrowkey
go next card
end arrowkey
9. If you have to declare many global variables at the beginning of your script, you can declare them in the same line by separating them with a comma. For example, “global var1,var2,var3,var4.”
10. You can edit your own patterns in the pattern windoid by double-clicking on them. These changed patterns will stay with the particular stack and not overlap into other stacks.
11. If a user-defined function uses the same name as a HyperCard function, HyperCard defaults to the user-defined function. For example, if you have a function “average” that you have defined in a stack script, HyperCard will use that function and not its own built-in average function.
12. If you want a miniature picture of a card, you can do Copy Card from the menu, then Command-Shift-V to paste a miniature on your screen.
13. If you want to set more than one textstyle, you can say: “set textstyle of button to bold,italic,underline.” Also, if you want it to not have any textstyle after it has been set to a certain style, you can say: “set textstlyle of button to plain.”
14. The user pressing Command-Period can stop any script, even if an answer of ask dialog is on the screen.
15. Double-clicking in the Script Editor or in a field selects the entire word.
16. In a script, you might not know how many levels deep you are in calls to other handlers that have called you. “Exit to HyperCard” will pop you out of all sub-messages.
17. If you have had trouble getting the name of a card, here's the trick. Go to the card and ask: "get the short name of this card.” The short name will give you the name of the card, whereas the long name will give you the entire pathway to the card.
18. “Repeat” or “Repeat Forever” will continue on until an exit repeat or an exit to HyperCard is encountered.
19. In a field, drag with the Command key on a selection of text. HyperCard will put it into the message box, and you can then execute it by hitting return.
20. If the user cancels an “ask” dialog, HyperCard puts a null into the variable “it.” You can therefore check and see if “it” is empty, thereby knowing that the user clicked CANCEL.
21. Once you have set a button to an icon, you can set the button to not have an icon by saying: “set icon of button to zero.”
22. Only a locked text field can receive mouse messages such as mouseup, mousedown, mousewithin, etc.
23. The characters ≥ and ≤ work as HyperCard operators "greater than or equal" and “less than or equal”, as well as the more normal >= and <=. You get these characters by pressing Option-Greater Than or Option-Less Than.
24. You can get rid of your screen altogether by “set visible of cardwindow to false.”
25. Functions are not to be defined within message handlers.
==========
Programming Function Keys
by Sioux Lacy
The HyperTalk command “functionkey” allows you to associate a script with any of the function keys on an extended keyboard. To program a functionkey, use the following format:
On functionkey thekey
if thekey is 5 then
— add any script
end if
if thekey is 6 then
put the heapspace — or whatever
end if
end functionkey
You can put the script into a card, background, stack or home script, depending on how widely you want your functionkeys to be “detected.”
The following script will make a functionkey that will automatically move anything selected on the card into the background. The beauty of using type “x” with commandkey instead of domenu “cut” is that it transcends the fact that the Edit menu reflects the object selected. The command key simply calls that menu item, so it doesn’t matter if it says “cut button” or “cut picture.” I’ve installed this script into my Home card, so that I can access it from any stack.
On functionkey
if whatkey is 6 then
type “x” with commandkey -- Cut whatever is selected
domenu “background” -- enter the background
type “v” with commandkey -- Paste it
domenu “background” — leave the background
end if
end functionkeys
==========
ICONMAKER
As you know, HyperCard comes with many different button ICONs ready for your immediate use. Just double-click on any button while in the Button Tool and you will see a dialog box with a button called Icon. Clicking on this button allows you to scroll through and choose one of many interesting icons for your buttons.
One thing users have wanted was the ability to create and install other icons in their stacks. IconMaker™ solves that problem. Now you can create Icons and put them into stacks very easily.
All you do is install IconMaker in your System file and select it from your DA menu. An empty (32 X 32) ICON sized square appears and is capable of copying anything you click on within its boundaries. ICN#s (Finder Icons) are created when you just click your mouse and ICONs are created if you press the command key and click.
ICON resources are what HyperCard uses. You will be asked via Standard File where you want the ICON. If you want to use it only in your personal stacks you can click on your Home card. This makes the ICON available to all of your stacks that use your Home card. If you want other people to enjoy your newly created ICON, you will have to install it directly into the stacks you will be sharing.
Pressing on the H key with the Icon Maker selection square showing gives you HELP information. Pressing any other key cancels Icon Maker.
IconMaker allows you to use clipart, or create your own art work and turn it into usable ICONs for sharing in five clicks of a mouse. This is a really great utility for HyperCard.
Icon Maker 2.1 was created by Steve Fine. I have spoken to Steve and he has allowed me to put Icon Maker 2.1 in the AHUG StackWare shareware folder. You will be able to take it and see if it meets your needs just as you are invited to share in all of the stacks that we bring to our meetings every other Thursday. Steve only asks that if you like it to please send him a contribution so that he may continue to develop useful tools for you. His address is:
Steve Fine
504 Linden Rd.
University Park, PA 16802
==========
TELL APPLE
You can use this form to notify the HyperCard team of problems, bugs, and enhancement requests.
Date:
Name:
MailStop or Address:
Phone:
Versions of:
a. HyperCard
b. Associated software
c. System Software
1. System
2. Finder
3. ImageWriter
4. LaserWriter file
5. Any others
Type of Macintosh:
Peripherals:
Description of problem, suggestions or comments:
==========
Vol 1 Number 3
In this third issue of WINDOID, we will continue to cover importing text into HyperCard™. Gary Bond, one of Apple’s outstanding HyperCard test team members, wrote a universal import button that takes into consideration nearly everything. You can now create a button that imports MacWrite™, Microsoft Word™, many database files, and even HyperCard stacks! We think you are going to enjoy this.
Phil Wyman, another tester, has provided us with more of his highly acclaimed power-user tips and has taken a stab at explaining some of the more interesting aspects of HyperCard properties.
In the two previous issues, there were some mistakes. I would like to apologize for any inconvenience or frustration they might have caused and rectify them. The errata will appear on page seven under WHOOPS. I generally get all the text stuffed into the WINDOID newsletter moments before the Thursday meeting, and sometimes I miss something. Many of the excellent scripters that avidly read WINDOID have noticed my lapses and have provided me with needed repairs. For their kind assistance, I offer my thanks.
WINDOID provides an opportunity for its readers to contribute to the ongoing growth and excellence of HyperCard. With your assistance we can continue to bring to HyperCard added depth and functionality. In the back of every issue will be a form for you to keep by your Macintosh™. This form will allow you the unique opportunity to participate directly in the continued development of HyperCard.
We will read all the forms returned and address questions that are being asked by HyperCard users. We will ask the team and provide you with an answer and publish the answers in this newsletter. In this way we can gather information and provide for your needs in future versions of HyperCard.
WINDOID is trying to make a difference in the way that you work with HyperCard. We need your input. What sort of stacks are you using, what kinds of stacks are you creating, and what are some of the joys and frustrations you are experiencing. We really want to know!
ERRATA -- ISSUE #1:
In the first issue Gary Bond showed us how to find out which line of a scrolling field the user has clicked on. Apple employee Brian McGhie found a small flaw and wrote me the following letter:
The question was asked, “How can I find out which line of a field a user has clicked in?” The response was a method that would work in static fields, and then further developed into a method for scrolling fields. The function Clickline as given for scrolling windows only works if the scrolling field is (in pixels) an integer multiple of the textheight. A corrected version of Clickline appears below.
Function Clickline
return (trunc(((scroll of the target) ¬
+ (item two of the clickloc) ¬
- (item two of the rect of the target)) ¬
div the textheight of the target) + one)
End Clickline
The idea is to calculate the number of pixels from the top of the field to the position that you clicked on. So you take the number of pixels that have scrolled offscreen, and add in the vertical position of the mouseclick minus the vertical position of the top of the field. This sum is the total number of pixels from the logical top of the window —not the visual top. Divide by the height of the font to get the number of lines. Since this number is not always an integer, truncate it. The result is a zero based count of lines. Add one and return the correct line number that was clicked in.
ERRATA -- ISSUE #2:
Robin Shank provided us with a “How to Program FunctionKeys” in HyperTalk script. We left out a word, and the script will not work without it. The script should read:
On functionkey whatkey
if whatkey is 6 then
type "x" with commandkey — Cut whatever is selected
domenu "background" — enter the background
type "v" with commandkey — Paste it
domenu "background" — leave the background
else
pass functionkey
end if
end functionkey
There are two other stacks on the StackWare™ server that deserve serious attention. The AIDS stack is a perfect representation of how HyperCard can be used in an incredibly invocative eye and heart grabbing style. This stack is not only visually and emotionally gripping, but is an excellent example of how to use HyperCard as a powerful vehicle to move you through diverse information. You should get this stack.
Finally, Tree Frog Studio software presents CheapSequencer. Tree Frog has given us a music sequencer that must be seen and heard to be believed. These innovative stackware developers are interested in entertaining us with great graphics and functional stackware tools.
It’s stacks and people like these that really show the power and versatility of HyperCard.
We hope you have enjoyed reading WINDOID and have found it to be interesting and informative. We care enough to take the time to give you the most up-to-date information about HyperCard, and we would like to make a request for a little of your time. There is a form that follows this editorial; please fill it out if you will. We are very interested in hearing from you. What sort of stacks are you using, what kind of stacks are you creating, and what are your joys and frustrations in using HyperCard.
You have the unique opportunity to communicate directly with Bill, Dan, and the entire HyperCard development team. We really want to know what you would like to see in HyperCard and are more than willing to give you what you want. What we need to make this happen is your input. Let us know what you think. We can address it in WINDOID or perhaps the next revision of HyperCard. You can make a difference in the world by communicating with us. Don’t pass up the opportunity!
==========
If you have a bug, suggestion, comment, or just want to know
the best way to do something in
HyperCard, you can fill out the form and send it to:
AHUG c/o David Leffler
Apple Computer, Inc.
MS/27-AQ
20525 Mariani Ave.
Cupertino, CA 95014
Or copy the format and
Apple-Link™ it to:
HYPERBUG$
==========
Danny Goodman presents Focal Point
At the last Apple HyperCard User Group meeting , Danny Goodman, author of The Complete HyperCard Handbook, presented to an appreciative audience his incredible business productivity stack Focal Point™. It will be released soon by Activision™. We were all amazed at the incredible graphics and awesome features he has scripted into it. Danny, as you might know, is not a programmer and has always been frustrated by his inability to turn his ideas into software. HyperCard has empowered him to not only turn his ideas into reality, but to allow him the opportunity to share his ideas with the world. Thank you Danny!
Amanda Goodenough, author of the Inigo and My Favorite Camel series of wonderful adventures, was also on hand. Her obvious love of stories and great presentation style captivated the audience. Amanda continues to enhance and produce more of these non-textual stories and has graciously allowed us to place them in an Amanda’s Stacks folder on the AHUG StackWare™ server. My Favorite Camel is a favorite of mine, and I think everyone should see it and share it with someone they love.
There is one other stack on the StackWare™ server that deserves serious attention. The AIDS stack is a perfect representation of how HyperCard can be used in an incredibly invocative eye and heart grabbing style. This stack is visually gripping and is an excellent example of how to use HyperCard as a powerful vehicle to move you through diverse information. You should get this stack.
====================
HyperCard Hints
by Phil Wyman
1. If you get tired of pulling the Tools Windoid off of the menubar when you need it, try Option-Tab, which will tear it off for you! Also, if the Tools Windoid is in a paint tool, hitting Tab will tear off the Patterns Windoid.
2. If you have a line in your script that is longer than the editor window, you can place an Option-Return at a space in the line to break it into two smaller lines. The two lines will execute in the same way as the original line. (Do not place the Option-Return into the middle of a quoted string. Also, if you use the Option-Return in a comment, remember that every line of a comment must start with a double hyphen!)
3. For those programmers out there who are used to "for next" loops, there is a "next repeat" command in HyperTalk which works in a repeat loop a lot like a "next" command in a "for next" loop. The “next repeat” command does not execute anything that follows it in the repeat loop, but rather starts executing at the beginning of the repeat loop.
Also, if you wish to exit the repeat loop altogether, without executing anymore of the lines in the repeat loop, then use "exit repeat".
Note: If you want to exit the entire message handler from anywhere in the handler, use "exit <handlername>" (i.e., "exit mouseup").
If you wish to leave the handler but wish the current message to be sent on up the hierarchical path from where it is now, then use "pass <handlername>".
4. When concatenating two strings, you can add a space between the two strings by using two ampersands "&&" instead of just one "&".
5. A shorthand for "button" in HyperTalk is "btn". A shorthand for "background" is "bkgnd".
6. You can copy buttons, fields, backgrounds or cards between stacks. This is a very powerful feature of HyperCard.
7. For those of you with the regular size Mac Plus or Mac SE screens, try this for a thrill:
Set loc of cardWindow to 10,50
You will see what people on large screens see all the time, a window title bar which states the pathname of the window you are viewing. (To reset your cardWindow, "Set loc of cardWindow to 0,0".)
8. If you are in any tool other than the Browse tool, you can return to the Browse tool by Command-Tab.
9. When you are in the Button tool, you can Command-Drag to create a new button. Option-Drag on a button and you will drag a copy of the button.
10. A first attempt at a small treatise on the use of "the","of", and "()" in HyperTalk:
In general, either "the", "of", or parentheses () are required to signal HyperTalk that a function or property is to be activated.
PROPERTIES:
With button, card, background, stack, and window properties, "the" is optional, but you need "of". Also, properties never have parentheses. You can say:
put hilite of button 1
put the hilite of button 1
Since there is no "of" to activate it, you cannot say:
put the hilite button 1
If you are using a global or painting property, you need "the", since there is no "of" to activate the property. For instance, you can say:
put the lockScreen
put the textAlign
However, you cannot put the property by saying:
put lockScreen
because HyperCard will think you are using lockScreen as a variable, not a property.
FUNCTIONS:
Either "the", "of", or parentheses () are required with a function.
However, you cannot mix "the" with parentheses in a system function. For instance, you cannot say:
put the charToNum("a")
You are allowed to say:
put the chartonum of "a"
put chartonum("a")
put the chartonum of ("a")
If a system function has more than one argument, it will always require parentheses. For user-defined functions, you must always use parentheses, even if there are no arguments—i.e., userFunction().
If a function does not use "of" or "()", then "the" is required! For example, "date" doesn’t work without "the", since there is not an "of" or "()" to activate the function. You can say:
put the date
But you cannot say:
put date
because HyperTalk will assume that "date" is a variable. This concept of insisting on a "the" to activate the function allows for future expansion of more system functions, since system functions will not be able to collide with variables that users already have in their scripts.
==========
The Universal Button
by Gary Bond
Last issue we dealt with importing text. While those approaches are reliable, they are also very slow and don’t account
for a number of problems that might occur along the way. Consistent with our goal to provide you with the best, this issue contains a script for a universal import button which does both kinds of import (text and data). To use it, type it
into any button script.
In addition to importing text files it also imports Macwrite and Word documents and even Hypercard stacks! This
version of the import button fixes bugs both in Hypercard and in previous button versions.
on mouseUp
global cardcount,startcard,memory,header
get userlevel
put it into item 1 of memory
set userlevel to 5
set lockmessages to true
set lockscreen to true
put short id of this card into startcard
answer "Import text file as:" with "Data" or "Text" or "Cancel"
if it is "Cancel"then Cleanexit
if it is "Text" then
answer "Include header information in fields?" with "Yes" or "No"
put it into header
Importext
else
Importdata
end if
go next card
Cleanexit "Compact"
end mouseup
on importext
global cardcount,startcard,memory,header
put 0 into cardcount
repeat
ask "Name or pathname of text file to import:" with item 2 of memory
if short name of this stack is in it then
if "," is not in memory then put "," after memory
put it into item 2 of memory
answer "Can’t import current stack!" with "Ok"
next repeat
end if
if it is empty then
Cleanexit
else
exit repeat
end if
end repeat
put it into filename
if "," is not in memory then put "," after memory
put it into item 2 of memory
set cursor to 4
open file filename
repeat
read from file filename for 16384
if it is empty and cardcount is 0 then
answer "Could not find file: " & filename with "Ok"
close file filename
Cleanexit
end if
if it is empty then exit repeat
put return after it
domenu "New card"
add 1 to cardcount
domenu "New field"
set name of card field (number of card fields) to "Import"
set style of card field "Import" to scrolling
drag from the loc of card field "Import" to 0,62
drag from 190,100 to 512,342
if header is "Yes" then
put "Characters:" && number of chars in it & return & return before it
put "Lines:" && number of lines in it & return before it
put "File:" && filename & return before it
put "Import card:" && cardcount & return before it
end if
put it into card field "Import"
end repeat
close file filename
if header is "Yes" then
repeat until the short id of this card is startcard
put "of" && cardcount after line 1 of card field "Import"
go previous card
end repeat
else
go card id startcard
end if
end importext
on importdata
global filename,cardcount,startcard,memory,header
put empty into delimiters
put empty into filename
put 0 into cardcount
put 0 into limit
put 0 into fieldcount
repeat until delimiters is not empty
put 0 into nofields
answer "Use Tab and Return as delimiters?" with "Yes" or "Other" or "Cancel"
if it is "Cancel" then mouseup
if it is "Yes" then put "9,13" into delimiters
if it is "Other" then
repeat until ((item 1 of it > 0 and item 1 of it < 256)¬
and (item 2 of it > 0 and item 2 of it < 256)) or it is empty
ask "Enter two comma separated Ascii delimiters:" with empty
put it into delimiters
end repeat
end if
end repeat
if item 1 of delimiters is item 2 of delimiters then put 1 into nofields
answer "Include header information in fields?" with "Yes" or "No"
put it into header
repeat
ask "Name or pathname of text file to import:" with item 2 of memory
if short name of this stack is in it then
if "," is not in memory then put "," after memory
put it into item 2 of memory
answer "Can’t import current stack!" with "Ok"
next repeat
end if
if it is empty then
if cardcount > 0 then
close file filename
CleanExit
end if
Importdata
else
exit repeat
end if
end repeat
put it into filename
if "," is not in memory then put "," after memory
put it into item 2 of memory
set cursor to 4
open file filename
repeat
read from file filename until (numtochar of item 2 of delimiters)
if it is empty and cardcount is 0 then
answer "Could not find file: " & filename with "Ok"
close file filename
Cleanexit
end if
if it is empty then exit repeat
if chartonum(last character of it) is not item 2 of delimiters then
put item 2 of delimiters into temp
if temp is 9 then put "Tab" into temp
if temp is 13 then put "Return" into temp
answer "Can’t find record delimiter: " && temp with "Ok"
close file filename
cleanexit
end if
put empty into last character of it
if (numtochar of item 1 of delimiters) is not in it and nofields is 0 then
put item 1 of delimiters into temp
if temp is 9 then put "Tab" into temp
if temp is 13 then put "Return" into temp
answer "Can’t find field delimiter: " && temp with "Help" or "Ok"
if it is "help" then
answer "Use double record delimiters for records..." with "Continue”
answer "with no field delimiters. Example: 13,13" with "Ok"
end if
close file filename
Cleanexit
end if
if (numtochar of item 1 of delimiters) is not "," and nofields is 0 then
repeat until (numtochar of item 1 of delimiters) is not in it
put "," into character offset((numtochar of item 1 of delimiters),it) of it
end repeat
end if
if cardcount is 0 then
domenu "New background"
else
domenu "New card"
end if
add 1 to cardcount
if nofields is 0 then
put the number of items in it into limit
else
put nofields into limit
end if
repeat with count = 1 to limit
if cardcount is 1 then
add 1 to fieldcount
if fieldcount < 125 then
domenu "New field"
else
answer "No more fields can be created!" with "Ok"
Cleanexit "Compact"
end if
end if
put "Field" & count into fieldname
set name of bkgnd field (number of bkgnd fields) to fieldname
set style of bkgnd field fieldname to scrolling
If nofields is 0 and header is "Yes" then
put "Field" && count && "of" && the number of items in it & return into bkgnd field fieldname
put "Record" && cardcount && "of file:" && filename & return & return after bkgnd field fieldname
end if
if nofields is 0 then
put item count of it & return after bkgnd field fieldname
else
put it & return after bkgnd field fieldname
end if
end repeat
choose browse tool
end repeat
close file filename
go card id startcard
end importdata
on Cleanexit var
global memory
if param(1) is "compact" then
domenu "Compact stack"
end if
choose browse tool
set userlevel to item 1 of memory
set lockscreen to false
set lockmessages to false
exit to hypercard
end Cleanexit
==========
Vol 1 Number 4
In the fourth issue of WINDOID, we address more of the many questions and problems people have sent in. Quite a number of people have expressed interest in moving a group of buttons or fields on a card. Sioux Lacy, one of our outstanding HyperCard testers, has given us a way to group buttons and/or fields and move them, in a group, within a card and even onto other cards. Sioux has also written for us an article on Finding multi-word strings in blocks of text. This is one that everyone has asked for.
Phil Wyman, with assistance from Steve All, two more great HyperCard testers, have given us further HyperCard user tips. We really appreciate all of the cards people have sent us with the tips they have found. In this way we can pass on useful tips to many hundreds of HyperCard users.
Paul Foraker, our newest tester, has submitted an AutoLink script. Using this great little shortcut for scripting buttons gives you another productivity tip I am sure you will find interesting.
Steve Maller has done it again! ResCopy is his latest XCMD effort to give us a safe, elegant, and easy way to move resources around in HyperCard. This version is his “shipping” version and does not have a time bomb in it. You are free to give it away to your HyperCarding friends. This is one stack that people who do not have it will lust for.
Sioux Lacy has given us Groupies 1.3, featured in this issue of WINDOID. This is a must stack for serious HyperCard users. I really appreciate Sioux’s efforts in bringing us all of these great articles and I am equally sure that you will also.
These two stack are on the Apple HyperCard User Group file server and can be obtained only here in Cupertino. If your favorite bulletin board does not have them, please ask them to have someone upload them.
==========
AutoLink
by Paul Foraker
Shortly after you get HyperCard installed on your hard disk, you may notice that you are collecting a large number of other people’s stacks. One way of keeping track of all of them is to stuff them into a folder and put a button for them on a card in your Home stack. Since the original Home card already comes with 19 buttons (and room for about 24), you might want to make another card for holding buttons that take you to your miscellaneous stacks. To avoid having to name and link all the buttons on a new card to the stacks I’ve collected, I wrote a variation on Danny Goodman’s script which takes you to a stack even though the button has no script or link.
In this version, a button named “new button” opens the familiar Standard File dialog and then gets the name of whatever stack you select, changes the name of itself (the button) to the selected stack, then goes there. If the button already has a name (other than “new button”), the script simply goes to the stack. This eliminates the necessity for linking or scripting multiple buttons on a card.
To start from scratch from your Home card, select New Card (CMD-N) and title the new card “BackYard” (or anything else fun). Type the script below into the script window for the card. (You can skip over typing the comments if you wish.) Then make a new button (you can select an icon for it — I use the generic stack icon). Now hold down the Option key and drag copies of the “new button” around onto your card. (You can use the Shift key to constrain the movement so they’re lined up neatly.)
Next, select the Browse tool again and click on one of your new buttons. You’ll get Standard File asking you “where
is the stack you want?” Double click on one of the stacks in the list, the new button will get a name change, and
you’ll be off to the new stack. From there, you can hit the escape (~) key to go right back to the BackYard to AutoLink another button.
--AutoLink script
--variation on Danny Goodman’s script
--by Paul Foraker
on mouseUp
put the short name of this stack ¬
into thisStack --saving the name for
--use later
get the short name of the target --puts the ‘short’ name of the
--button you clicked on into ‘it’
if it is “new button” then --Oh boy... a new stack has arrived!
push card --saves the BackYard card id
--so we can come back to it
set lockMessages to true --stops any other scripts from running
set lockScreen to true --freezes the screen so we’re not
--distracted by fast moving cards.
go stack “the stack you want?” --since there is no stack by that
--name, HyperCard will respond by
--asking you where it is.
--Standard File will open and you
--can select a stack
--or click on Cancel.
get the short name of this stack --here we’re asking for the
--short name of the ‘new’ stack
if it is thisStack then --checking for clicking on the Cancel button
pop card --go back to our BackYard card
set lockScreen to false --unlocking the screen display
exit mouseUp --pretend it never happened
end if --end of checking for ‘cancel’
put it into stackName --putting short name of the stack into
--’stackName’
pop card --go back to our BackYard card
set the name of the target to stackName --rename the button
set showName of the target to true --we want to see the name
set the script of the target to empty --make sure there’s no script in
--the button
set lockScreen to false --unlocking the screen display
set lockMessages to false --now messages can fly around again.
end if --marks the end of the loop
--for a ‘new button.’
--now, we make sure you didn’t click on the card or background:
if the short name of target is the short name of this card then exit mouseUp
if the short name of target is the short name of this bkgnd then exit mouseUp
visual iris open to black --just for fun
go STACK it --‘it’ will be either the new stack or
—one that’s already been identified
end mouseUp
==========
HyperCard Hints
by Phil Wyman
1. There are some interesting properties in HyperTalk that you may not know about:
a. <the version> is a global property which tells you which version of HyperCard you are currently using. This property will become very useful after new versions are released. Since the new versions will have added features that old versions do not understand, stack developers will want to check to see if their stack is currently running on a version of HyperCard that supports those new features.
b. <the name> is another global property. It will tell you that the name of the program is HyperCard. I have not found a way to use this yet, so if anyone has any ideas, let me know.
c. <the diskspace> is a global property which will tell you how many bytes you have left on the drive that the current stack is located on.
2. You can send a message up the heirarchy manually by using the message box. For instance, if you want an OPENSTACK message sent without having to reopen your stack, just type OPENSTACK into the message box and hit return or enter. Any handler, starting with any handler in the current card, which uses OPENSTACK, will receive that message.
Some users are having trouble sending their own messages. In a script, you can just type the name of your message on a line by itself and that message will be sent. If HyperCard does not find a handler with that message, it will throw up a dialog telling you it can’t understand <message>.
You can also send a message with the <send> command. You can have difficulty with the <send> command if you are trying to send across stacks. Try going to the stack first before using <send>. For example:
send mouseup to button 1¬ of card 1 of stack "Home"
will generate a HyperCard error "expected end of line after send". To get the "mouseup" message to the button, try this:
go to card 1 of stack "Home"
send mouseup to button 1
3. When you are printing your script from the script editor, you do not have to print the whole script. If you want to just print a portion of your script, then select the part you want, then click on the print button. Only your selected text will print.
4. The Tab key moves you between fields on a card in the order of their field number (which can be changed with Bring Closer and Send Farther). But a useful fact for data entry is that Shift-Tab navigates you through fields in reverse order.
5. Choosing a selection with the Selection tool can leave you with a lot of extra white space surrounding your selection. And you may already know that Command-S shrinks a selection rectangle until there is no surrounding white space. What if you want a rectangular selection but no extra white space? Hold down the Command key before selecting with the Selection tool and just that will happen.
6. If you are writing commercial stacks and need to restrict the user-level, you may wish to tell users in your About Box that they can access “Full Menus” by holding down the Command key before clicking the menu.
7. So you think that those tiny pictures in “Recent” are neat? You can create them yourself. Copy a card and hold down the Shift key when pasting it back in. You’ll get an image of the card in miniature (but no actions from buttons or fields to type into).
There are three ways in which the script writer can inquire about the presence of a string in a block of text: FIND, CONTAINS and OFFSET.
These can be used separately or in combination.
The FIND command will highlight the next occurence of the first word of the string if all words in the string are somewhere on the card.
Another option is to test if a particular container (field or variable) CONTAINS the string.
This test will determine an exact match on the entire string.
The function OFFSET will return the character in the container on which the match begins. This can also be used to test IF the field/variable includes the string, since if it does NOT, offset will return 0. Depending on the context of the search, the script writer may opt for one or a combination of these. If the scope of the search is small, and across known fields, CONTAINS or OFFSET can be used. However, if the search is across many fields in a large stack, FIND is a good mechanism to narrow down the number of fields that have to be examined to see if they CONTAIN the string.
To FIND a multi-word string
For example, you would like to find an exact match for the string “Hello there”. You will discover that HyperCard is generous in its find criteria, and also matches the following: “Hello world. Is there life out there?”
This can be problematic if the search is taking place inside a handler, rather than at the control of a human who can continue to hit the return key. The way to circumvent this is to do your match in 2 steps. Supposing you expect the match to be in a background field, try calling a function (until you’ve searched the entire stack) that does this:
function multiWordFind string
repeat with x = 1 to the number of bkgnd fields
if field x contains string then return "FOUND in field " & x
end repeat
return "NOT FOUND"
end multiWordFind
(If you expected the match to be in a card field, repeat also for the number of card fields.)
on searchStackFor string
set lockScreen to true
find string
if the result is "Not Found" then cleanExit¬
"This stack doesn’t contain: " & string
--Use the above two lines or use the script
--at the end as an alternate to find offset.
put the id of this card into startedHere
repeat
get multiWordFind (string)
if word 1 of it is "FOUND" then cleanExit it
go next card -- so a subsequent find won’t find the same
-- card over again
find string
if the id of this card is startedHere then cleanExit¬ "This stack doesn’t contain: " & string
end repeat
end searchStackFor
on cleanExit prompt
put prompt
set lockScreen to false
exit to HyperCard
end cleanExit
--Use the following as an alternate to determine the offset.
if word 1 of it is "FOUND" then
cleanExit it && "at character position" && offset¬
(string, the value of word 3 to 4 of it)
end if
====================
Grouping Buttons
by Sioux Lacy
Sioux Lacy, one of the outstanding HyperCard testers, has donated this script to provide you, the user, an often-desired script for moving a group of buttons and/or fields around on a card. We are always trying to give you what you ask for, so please let us know if this script is helpful to you. --Editor
Many users have asked about grouping objects. This stack presents a method for assigning to a group any number of buttons or fields, and then being able to move that group as a unit, or copying and pasting that group onto another card. This is accomplished with a series of handlers in a card field, called “menuField”. It looks somewhat like a menu, accepts clicks on any command that it displays, and can be copied and pasted onto another card.
The menuField has a Help option that allows the user to read about each of its options.
Note that the menuField needs to be a card field in order to work properly. And, when a group has been pasted, it will require re-grouping if its group identity is to work in the new context. Also, since it is difficult to select overlapping objects to be members of a group, it is recommended that they be positioned so they don't overlap.
Groupies 1.3 by Sioux Lacy, November 6, 1987. AppleLink comments to me at LACY1, or send mail to Sioux Lacy,
MS 27-AQ, 20525 Mariani Ave., Cupertino, CA 95014.